import java.util.Arrays;

public class test {
    public static String myToString(int[] arry){//Arrys.toString的功能实现
        String str="[";
        for (int i=0;i<arry.length;i++){
            str+=arry[i];
            if(i!=arry.length-1){
            str+="，";
            }
        }
        str+="]";
        return str;

    }

    public static void main(String[] args) {
        //实现数组的逆序
        int[]arry={1,2,3,4,5,6};
        System.out.println(Arrays.toString(arry));
        int i=0;
        int j=arry.length-1;
        while(i<j){
            int k=arry[i];
            arry[i]=arry[j];
            arry[j]=k;
            i++;
            j--;
        }
        System.out.println(Arrays.toString(arry));

    }
    public static void main2(String[] args) {
        //自己创建方法实现Arrys.toString
        int[] arry={1,2,3,4,5,6};
        System.out.println(myToString(arry));

    }
    public static void main1(String[] args) {
        //for-each--增强循环---用来打印数组
        int[] arry1={1,2,3,4,5};
        for(int x:arry1){
            System.out.println(x);
        }
        System.out.println();
        System.out.println("=========");
            String str = Arrays.toString(arry1);//Java官方提供的方法
        System.out.println(str);
    }
}
